﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using Taobao.Top.Api;
using Taobao.Top.Api.Request;
using Taobao.Top.Api.Domain;

namespace OpenService.Top
{
    public partial class Callback : System.Web.UI.Page
    {
        private string top_appkey;
        private string top_session;
        private string top_parameters;
        private string top_sign;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString.Count > 3)
            {
                top_appkey = Request.QueryString["top_appkey"];
                top_session = Request.QueryString["top_session"];
                top_parameters = Encoding.Default.GetString(Convert.FromBase64String(Request.QueryString["top_parameters"]));


                TopXmlRestClient client = new TopXmlRestClient("http://gw.api.tbsandbox.com/router/rest", "12149432", "2efe2139b6a3059d6bd7e5c952e2b4ba");
                TradesSoldGetRequest req = new TradesSoldGetRequest();
                req.Fields = "tid,seller_nick,buyer_nick,orders.oid,orders.iid,orders.title,orders.price";
                PageList<Trade> rsp = client.TradesSoldGet(req, top_session);
                List<Trade> trades = rsp.Content;
                long totalResults = rsp.TotalResults;
            }
            //TopXmlRestClient client = new TopXmlRestClient("http://gw.api.tbsandbox.com/router/rest", "12149432", "2efe2139b6a3059d6bd7e5c952e2b4ba");
            //UserGetRequest request = new UserGetRequest();
            //request.Fields = "user_id,nick,sex,created,location";
            //request.Nick = "tbtest520";
            //Taobao.Top.Api.Domain.User user = client.UserGet(request);

        }
    }
}